package pers.cocoadel.springcloud.service.impl;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import pers.cocoadel.springcloud.service.PaymentSerivce;

/**
 * @author rwby
 */
@Service
public class PaymentServiceImpl implements PaymentSerivce
{
    @Value("${server.port}")
    private String serverPort;

    //    @SentinelResource(value = "getPaymentById", blockHandler = "blockHandler", fallback = "fallback")
    @Override
    public String getPaymentById(String id)
    {
        return "serverPort:" + serverPort + " paymentId: " + id;
    }

    public static String blockHandler(BlockException exception)
    {
        return "服务器繁忙！";
    }

    public static String fallback()
    {
        return "fallback!";
    }


    @SentinelResource(value = "testLink", blockHandler = "")
    @Override
    public String testLink()
    {
        return "测试链路流控";
    }

    public String testLinkHandler(BlockException ex)
    {
        return "测试链路流控 服务器繁忙！/(ㄒoㄒ)/~~";
    }
}
